package com.yuxue.enumtype;


/**
 * 车牌颜色
 * @author yuxue
 * @date 2020-05-08 12:38
 */
public enum PlateColor {

    BLUE("BLUE","蓝牌", 100, 130, 40,245,55,255,5, 35),
    GREEN("GREEN","绿牌", 55, 100, 40,245,55,255,5, 35),
    YELLOW("YELLOW","黄牌", 1, 38,  40,245,55,255,5, 35),
    ALL("ALL","不区分", 1, 130,  40,245,55,255,5, 35),
    UNKNOWN("UNKNOWN","未知", 1, 180,  1,255,1,255,5, 35);

    public final String code;
    public final String desc;

    // Opencv cvSplit 8UC: 色调（H）范围： 0-180，饱和度（S）范围： 0-255，亮度（V）范围： 0-255
    // Opencv cvSplit 32F: 色调（H）范围： 0-360，饱和度（S）范围： 0-1，亮度（V）范围： 0-255
    // 色调对图像的分辨较为准确，各个颜色所对应的色调范围： Yellow 22- 38 Green 38-75 Blue 75-130
    public final int minH;
    public final int maxH;
    public final int minS;
    public final int maxS;
    public final int minV;
    public final int maxV;

    public final int equalizeMinH;
    public final int equalizeMaxH;

    PlateColor(String code, String desc, int minH, int maxH, int minS, int maxS, int minV, int maxV, int equalizeMinH, int equalizeMaxH) {
        this.code = code;
        this.desc = desc;
        this.minH = minH;
        this.maxH = maxH;
        this.minS = minS;
        this.maxS = maxS;
        this.minV = minV;
        this.maxV = maxV;
        this.equalizeMinH = equalizeMinH;
        this.equalizeMaxH = equalizeMaxH;
    }

    public static String getDesc(String code) {
        PlateColor[] enums = values();
        for (PlateColor type : enums) {
            if (type.code().equals(code)) {
                return type.desc();
            }
        }
        return null;
    }

    public static String getCode(String desc) {
        PlateColor[] enums = values();
        for (PlateColor type : enums) {
            if (type.desc().equals(desc)) {
                return type.code();
            }
        }
        return null;
    }


    public String code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

}
